package com.hyz.login.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyz.login.model.Pay;
import com.hyz.login.mapper.PayMapper;
import com.hyz.login.service.PayService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwq
 * @since 2022-11-29
 */
@Service
public class PayServiceImpl
        extends ServiceImpl<PayMapper, Pay> implements PayService {

    @Autowired
    private PayMapper payMapper;

    @Override
    public IPage<Pay> findAll(Integer registerid, Integer page, Integer limit) {
        QueryWrapper<Pay> wrapper = new QueryWrapper<Pay>();
        if (registerid!=null){
            wrapper.eq("registerid",registerid);
        }
        IPage<Pay> iPage = new Page<Pay>();
        iPage.setRecords(payMapper.findAll(registerid, page-1, limit));
        iPage.setTotal(payMapper.selectCount(wrapper));
        return iPage;
    }

    @Override
    public Integer addPay(Integer registerid, Integer money) {
        return payMapper.addPay(registerid, money);
    }
}
